package 小葱的01串;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] ch = in.next().toCharArray();
        int[] sum = new int[2];
        int[] count = new int[2];
        for (int i = 0; i < n; i++) {
            sum[ch[i] - '0']++;
        }
        int l = 0, r = 0, res = 0;
        while (r < n-1) {
            count[ch[r] - '0']++;
            while (r - l + 1 > n / 2) {
                count[ch[l++] - '0']--;
            }
            if (r - l + 1 == n / 2) {
                if (count[0] * 2 == sum[0] && count[1] * 2 == sum[1]) {
                    res += 2;
                }
            }
            r++;
        }
        System.out.println(res);
    }
}
